<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<%@ include file="/commons/global.jsp" %>
<script type="text/javascript">
    var examRecordDataGrid;
    $(function() {
        examRecordDataGrid = $('#examRecordDataGrid').datagrid({
            url : '${path }/examRecord/dataGrid',
            fit : true,
            striped : true,
            rownumbers : true,
            pagination : true,
            singleSelect : true,
            idField : 'id',
            sortName : 'Creat_Time',
	        sortOrder : 'asc',
            pageSize : 20,
            pageList : [ 10, 20, 30, 40, 50, 100, 200, 300, 400, 500 ],
             /* frozenColumns : [[  {
                title : 'id',
                field : 'id',
                width : 20,
                hidden : true
            } ] ], */
            columns : [ [ {
            	title : '考场编号',
                field : 'Exam_Site_Code',
                
                width : 60,
                sortable : true
            },{
                field : 'Course_SubCode',
                title : '子科目编号',
                width : 60,
                sortable : true
            },{
                field : 'Examinee_Num',
                title : '考生编号',
                width : 220,
                sortable : true
            },{
                field : 'Course_Code',
                title : '科目编号',
                width : 60,
                sortable : true
            },{
                field : 'Examinee_Name',
                title : '姓名',
                width : 90,
                sortable : true
            },{
                field : 'Exam_Site_Seat',
                title : '考试位置',
                width : 180,
                sortable : true
            },{
                field : 'Video_Score',
                title : '视频分数',
                width : 60,
                sortable : true
            },{
                field : 'File_Score',
                title : '文本分数',
                width : 60,
                sortable : true
            },{
                field : 'Status',
                title : '考试成绩是否有效',
                width : 120,
                sortable : true,
                formatter : function(value, row, index) {
                    if(value == 0) {
                        return "无效";
                    }else if(value == 1) {
                        return "有效";
                    }
                    return "未知";
                }
            },{
                field : 'Video',
                title : '视频',
                width : 180
            },{
                field : 'File',
                title : '文件',
                width : 180,
                sortable : true
            },  {
            	field : 'Creat_Time',
                width : '130',
                title : '创建时间',
                sortable : true
                
            } , {
                field : 'action',
                title : '操作',
                width : 150,
                formatter : function(value, row, index) {
                	
                    var str = '';
                        <shiro:hasPermission name="/examRecord/edit">
                            str += '&nbsp;&nbsp;|&nbsp;&nbsp;';
                            str += $.formatString('<a href="javascript:void(0)" class="examRecord-easyui-linkbutton-edit" data-options="plain:true,iconCls:\'fi-pencil icon-blue\'" onclick="editexamRecordFun(\'{0}\');" >编辑</a>', row.id);
                        </shiro:hasPermission>
                        <shiro:hasPermission name="/examRecord/delete">
                            str += '&nbsp;&nbsp;|&nbsp;&nbsp;';
                            str += $.formatString('<a href="javascript:void(0)" class="examRecord-easyui-linkbutton-del" data-options="plain:true,iconCls:\'fi-x icon-red\'" onclick="deleteExamRecordFun(\'{0}\');" >删除</a>', row.id);
                        </shiro:hasPermission>
                    return str;
                }
            } ] ],
            onLoadSuccess:function(data){
            	
                $('.examRecord-easyui-linkbutton-edit').linkbutton({text:'编辑'});
                $('.examRecord-easyui-linkbutton-del').linkbutton({text:'删除'});
            },
            toolbar : '#examRecordToolbar'
        });
    });
    
    function addexamRecordFun() {
        parent.$.modalDialog({
            title : '添加',
            width : 500,
            height : 300,
            href : '${path }/examRecord/addPage',
            buttons : [ {
                text : '添加',
                handler : function() {
                    parent.$.modalDialog.openner_dataGrid = examRecordDataGrid;//因为添加成功之后，需要刷新这个dataGrid，所以先预定义好
                    var f = parent.$.modalDialog.handler.find('#examRecordAddForm');
                    f.submit();
                }
            } ]
        });
    }
    
    function deleteExamRecordFun(id) {
        if (id == undefined) {//点击右键菜单才会触发这个
            var rows = examRecordDataGrid.datagrid('getSelections');
            id = rows[0].id;
        } else {//点击操作里面的删除图标会触发这个
            examRecordDataGrid.datagrid('unselectAll').datagrid('uncheckAll');
        }
        parent.$.messager.confirm('询问', '您是否要删除当前考生？', function(b) {
            if (b) {
                progressLoad();
                $.post('${path }/examRecord/delete', {
                    id : id
                }, function(result) {
                    if (result.success) {
                        parent.$.messager.alert('提示', result.msg, 'info');
                        examRecordDataGrid.datagrid('reload');
                    } else {
                        parent.$.messager.alert('错误', result.msg, 'error');
                    }
                    progressClose();
                }, 'JSON');
            }
        });
    }
    
    function editexamRecordFun(id) {
        if (id == undefined) {
            var rows = examRecordDataGrid.datagrid('getSelections');
            id = rows[0].id;
        } else {
            examRecordDataGrid.datagrid('unselectAll').datagrid('uncheckAll');
        }
        parent.$.modalDialog({
            title : '编辑',
            width : 500,
            height : 300,
            href : '${path }/examRecord/editPage?id=' + id,
            buttons : [ {
                text : '确定',
                handler : function() {
                    parent.$.modalDialog.openner_dataGrid = examRecordDataGrid;//因为添加成功之后，需要刷新这个dataGrid，所以先预定义好
                    var f = parent.$.modalDialog.handler.find('#examRecordEditForm');
                    f.submit();
                }
            } ]
        });
    }
    
    function searchexamRecordFun() {
        examRecordDataGrid.datagrid('load', $.serializeObject($('#searchExamRecordForm')));
    }
    function cleanexamRecordFun() {
        $('#searchExamRecordForm input').val('');
        examRecordDataGrid.datagrid('load', {});
    }
</script>
<div class="easyui-layout" data-options="fit:true,border:false">
    <div data-options="region:'north',border:false" style="height: 30px; overflow: hidden;background-color: #fff">
        <form id="searchExamRecordForm">
            <table>
                <tr>
                    <th>姓名:</th>
                    <td><input name="examineeName" placeholder="请输入考生姓名"/></td>
                    <th>创建时间:</th>
                    <td>
                        <input name="createdateStart" placeholder="点击选择时间" onclick="WdatePicker({readOnly:true,dateFmt:'yyyy-MM-dd HH:mm:ss'})" readonly="readonly" />至
                        <input  name="createdateEnd" placeholder="点击选择时间" onclick="WdatePicker({readOnly:true,dateFmt:'yyyy-MM-dd HH:mm:ss'})" readonly="readonly" />
                        <a href="javascript:void(0);" class="easyui-linkbutton" data-options="iconCls:'fi-magnifying-glass',plain:true" onclick="searchexamRecordFun();">查询</a>
                        <a href="javascript:void(0);" class="easyui-linkbutton" data-options="iconCls:'fi-x-circle',plain:true" onclick="cleanexamRecordFun();">清空</a>
                    </td>
                </tr>
            </table>
        </form>
    </div>

    <!-- <div data-options="region:'center',border:false"  style="overflow: hidden;">
        <table id="examRecordTreeGrid"></table>
    </div> -->
    <div data-options="region:'center',border:true,title:'考生列表'" >
        <table id="examRecordDataGrid" data-options="fit:true,border:false"></table>
    </div>
    <div id="examRecordToolbar" style="display: none;">
        <shiro:hasPermission name="/examRecord/add">
            <a onclick="addexamRecordFun();" href="javascript:void(0);" class="easyui-linkbutton" data-options="plain:true,iconCls:'fi-plus icon-green'">添加</a>
        </shiro:hasPermission>
    </div>
</div>